Skip to content

support length() on Run-end encoding arrays - #9838

Merged
alamb merged 2 commits into
apache:mainfrom
Rich-T-kid:rich-T-kid/ree-string-support
Apr 27, 2026
Merged

support length() on Run-end encoding arrays#9838
alamb merged 2 commits into
apache:mainfrom
Rich-T-kid:rich-T-kid/ree-string-support

Conversation

@Rich-T-kid

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

works towards closing #3520, adds run-end encoding support for legnth operations when the values array is valid.

Rationale for this change

REE is unsupported to length

What changes are included in this PR?

Introduces a macro to handle each REE run-end index type, eliminating duplicated logic across match arms. The macro uses new_unchecked instead of try_new to skip redundant validation, since the input is already a valid REE array and length has its own error handling, the invariants are guaranteed to hold before the unchecked call.

Are these changes tested?

Yes.

Are there any user-facing changes?

Yes, this allows callers to invoke length() directly on REE-encoded columns without materializing or casting to a primitive array first.

@github-actions github-actions Bot added the arrow Changes to the arrow crate label Apr 27, 2026
@Rich-T-kid

Copy link
Copy Markdown
Contributor Author

hey @Jefffrey I saw you were interested in my previous PR #8019, im picking up work on the REE Epic again. could you please review this when you have a chance

@Jefffrey Jefffrey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should introduce something like AnyDictionaryArray but for run arrays, which could simplify much of the code required here 🤔

(As a followup)

@Rich-T-kid

Copy link
Copy Markdown
Contributor Author

yea I think that would be neat. Im going to work on #7693 if theres a similar need ill make a PR that creates an Any_REE_Array and then update this PR & that PR to use it instead of duplicating code

@Rich-T-kid

Copy link
Copy Markdown
Contributor Author

@Jefffrey do I need to click on something else to merge the PR?

@alamb

alamb commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

@Jefffrey do I need to click on something else to merge the PR?

no, we'll handle merging it. Thank you

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Rich-T-kid and @Jefffrey

macro_rules! ree_length {
($array:expr, $run_type:ty, $k:expr, $v:expr) => {{
let ree = $array.as_run_opt::<$run_type>().unwrap();
let inner_value_lengths = length(ree.values().as_ref())?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this pattern of 'replaces the values of the REE array' is probably common enough to warrant its own function on RunArray eventually. Maybe some thing like

let out_ree = ree.with_new_values(inner_value_lengths)

And then internally it can update the data type and that the number of inner values is correct 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea I agree, similar to jefffrey's comments if I come across it while working on another PR ill make a PR addressing it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alamb
alamb merged commit b4c02d0 into apache:main Apr 27, 2026
18 checks passed
Rich-T-kid added a commit to Rich-T-kid/arrow-rs that referenced this pull request Jun 2, 2026
# Which issue does this PR close?
works towards closing apache#3520, adds run-end encoding support for legnth
operations when the values array is valid.
<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax.
-->

# Rationale for this change
REE is unsupported to length
<!--
Why are you proposing this change? If this is already explained clearly
in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand
your changes and offer better suggestions for fixes.
-->

# What changes are included in this PR?
Introduces a macro to handle each REE run-end index type, eliminating
duplicated logic across match arms. The macro uses **new_unchecked**
instead of **try_new** to skip redundant validation, since the input is
already a valid REE array and length has its own error handling, the
invariants are guaranteed to hold before the unchecked call.
<!--
There is no need to duplicate the description in the issue here but it
is sometimes worth providing a summary of the individual changes in this
PR.
-->

# Are these changes tested?
Yes.
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code

If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
-->

# Are there any user-facing changes?
Yes, this allows callers to invoke **length()** directly on REE-encoded
columns without materializing or casting to a primitive array first.
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.

If there are any breaking changes to public APIs, please call them out.
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants